﻿using HeerCards.Info;
using System.Collections.Generic;
using System.IO;

namespace HeerCards.Helper
{
    public class HCConfigLoader
    {
        public static List<CostUnit> loadCostUnitsFromFile(string path)
        {
            if (!File.Exists(path))
            {
                File.Create(path).Close();
            }
            var CostUnits = LitJson.JsonMapper.ToObject<List<CostUnit>>(File.ReadAllText(path));
            if (CostUnits == null)
            {
                CostUnits = new List<CostUnit>();
                //防止json为空bug
            }
            return CostUnits;
        }
        public static GobalSetting loadGobalSettingFromFile(string path)
        {
            if (!File.Exists(path))
            {
                File.Create(path).Close();
            }
            var gobal = LitJson.JsonMapper.ToObject<GobalSetting>(File.ReadAllText(path));
            if (gobal == null)
            {
                gobal = new GobalSetting();
                //防止json为空bug
            }
            return gobal;
        }
    }

}